<%@include file="/taglib.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<form class="layui-form"  action="${not empty sysUser?'sysUser!update.do':'sysUser!add.do'}" style="margin: 15px;" id="saveOrUpdateForm">
  <input type="hidden"  name="id" value="${sysUser.id}" />
  <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-inline">
      <input type="text" name="username" required  lay-verify="required"  placeholder="请输入用户名"  
      	value="${sysUser.username}" class="layui-input ${not empty sysUser?'layui-disabled':''}" ${not empty sysUser?'disabled':''}    />
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">名称</label>
    <div class="layui-input-inline">
      <input type="text" name="name" required  lay-verify="required" placeholder="请输入名称" value="${sysUser.name}" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
      <label class="layui-form-label">角色</label>
      <div class="layui-input-block">
       <c:forEach items="${authRoleList}" var="r">
       	  <input type="checkbox" name="roleIds"
	       	  <c:forEach items="${userRoles}" var="ur">
	       	  	 ${ur.roleid eq r.id?'checked="checked"':''}
	       	  </c:forEach>
       	  value="${r.id}" title="${r.name}">
       </c:forEach>
   	  </div>
    </div>
  <div class="layui-form-item">
    <label class="layui-form-label">邮箱</label>
    <div class="layui-input-inline">
      <input type="text" name="email" placeholder="请输入邮箱"   value="${sysUser.email}" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">电话</label>
    <div class="layui-input-inline">
      <input type="text" name="phone" placeholder="请输入电话"   value="${sysUser.phone}" class="layui-input"/>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">状态</label>
    <div class="layui-input-block">
      <input type="radio" name="state" value="0" title="正常" ${sysUser.state eq '0'?'checked':''}  ${empty sysUser?'checked':''} />
      <input type="radio" name="state" value="1" title="禁用" ${sysUser.state eq '1'?'checked':''} />
    </div>
  </div>
  <!--隐藏提交按钮，用于触发表单校验 -->
  <button lay-filter="saveOrUpdate" lay-submit class="layui-hide" />
</form>
<script>
	form.render();//重新渲染表单
	form.on('submit(saveOrUpdate)', function(data){//表单提交方法
 		getJsonByajaxForm("saveOrUpdateForm",'',function(data){
			if(data.result){
				layer.closeAll('page'); //关闭信息框
				layer.alert($('.layui-layer-btn0').text()+"成功!",function(){
					$('#search').click();
				}); 
			}else{
				l.alert(data.msg);
			}
		},true); 
		return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。									
	}); 
</script>
